# -*- coding: utf-8 -*-


# cmap2owl -- Helper application to convert from concept maps to OWL ontologies
# Copyright (c) 2008-2013  Rodrigo Rizzi Starr
#  
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#  
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#  
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.


'''
Base class with the interface of the rules used in a mapper

@author: Rodrigo Rizzi Starr
@copyright: Copyright © 2008-2013 Rodrigo Rizzi Starr
@license: MIT License
@contact: rodrigo.starr@gmail.com
'''


# Project imports
from OWLSerializer import OWLSerializable
from infoProvider import InfoProvider
from actionProvider import DummyActionProvider
from log import log
log.debug("Loaded...")

     
class MapperRule(OWLSerializable):
    """Represents a rule or heuristic that maps a certain feature from a CMap to
       an OWL ontology
    """
    
    def __init__(self, name, db, rules, classifiers=[]):
        """Name is a rule name, db is the rule database, rules is a list of
           strings each with a prolog rule, classifiers is a list of classifiers
           used by the rule.
        """
        
        self.name = name
        self.db = db
        self.rules = rules
        self.classifiers = classifiers
        
        OWLSerializable.__init__(self)
    
    def createRule(self, phrases=[]):
        '''Instantiates this rule in a rule database. Phrase is a list of
           Phrase's that the concept map contains, that can be used to perform
           semantic analysis.
        '''
        
        for rule in self.rules:
            self.db.assertz(rule)
            
    def getName(self):
        "Return the name of the rule"
        return self.name
    
    def getQuestions(self):
        "Return question related to this rule"
        pass
    
    def getOWLConcepts(self):
        "Returns the OWL elements that were inferred by this rule"
        pass
    
    def getInfoProvider(self):
        "Returns an info tuple about element"
        return InfoProvider()
    
    def getActionsProvider(self):
        "Returns an interface object with some options for that element"
        return DummyActionProvider()


